<template>
  <view class="search-component">
    <view class="search-layout" v-if="inputType == 1">
      <view class="search-box">
        <view class="search-text-list" @click="inputType = 2">
          <swiper
            class="swiper"
            circular
            :vertical="true"
            :autoplay="true"
            :interval="5000"
            :duration="300"
          >
            <swiper-item>
              <view class="swiper-item uni-bg-red"
                >闲鱼·大行自行车P8 <text class="t-icon t-icon-guanjun"></text
              ></view>
            </swiper-item>
            <swiper-item>
              <view class="swiper-item uni-bg-green"
                >闲鱼·自行车骑行头盔 <text class="red-text">HOT</text></view
              >
            </swiper-item>
            <swiper-item>
              <view class="swiper-item uni-bg-blue">闲鱼·冬季男款长裤</view>
            </swiper-item>
          </swiper>
        </view>
        <view class="search-btn">搜索</view>
      </view>
      <view class="qr-code">
        <text class="iconfont icon-weibiaoti--17"></text>
      </view>
    </view>
    <!-- 输入搜索内容 -->
    <view class="search-layout-input" v-if="inputType == 2">
      <view class="search-box">
        <view class="search-input-box">
          <text
            class="iconfont icon-weibiaoti--10"
            @click="inputType = 1"
          ></text>
          <input
            type="text"
            class="search-input"
            placeholder="请输入关键字"
            placeholder-class="placeholder-style"
            :focus="true"
          />
        </view>
        <view class="search-icon">
          <view class="ai-text">
            <text class="iconfont icon-AIchuangzuo"></text>
            <text class="icon-text">AI搜索</text>
          </view>
          <view class="right-content">
            <text class="iconfont icon-weibiaoti--44"></text>
            <view class="search-btn">搜索</view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import { defineComponent, reactive, toRefs } from "vue";
export default defineComponent({
  name: "search001",
  props: {},
  components: {},
  setup() {
    const data = reactive({
      inputType: 1,
    });

    return {
      ...toRefs(data),
    };
  },
});
</script>

<style scoped lang="less">
.search-component {
  .search-layout {
    background: #ffe600;
    display: flex;
    justify-content: space-between;
    height: 90rpx;
    padding: 10rpx 20rpx;
    box-sizing: border-box;
    .search-box {
      flex: 1;
      position: relative;
      .search-text-list {
        height: 100%;
        line-height: 70rpx;
        padding-left: 30rpx;
        box-sizing: border-box;
        color: #000;
        border-radius: 40rpx;
        background: #fff;
        overflow: hidden;
        .swiper {
          height: 100%;
          .t-icon-guanjun {
            width: 40rpx;
            height: 40rpx;
          }
          .red-text {
            color: #fff;
            height: 22rpx;
            line-height: 22rpx;
            background: red;
            padding: 0 8rpx;
            border-radius: 14rpx 14rpx 14rpx 0;
            font-size: 22rpx;
            margin-left: 10rpx;
            font-weight: 700;
          }
          .swiper-item {
            display: flex;
            align-items: center;
            font-size: 30rpx;
            font-weight: 300;
          }
        }
      }
      .search-btn {
        top: 5rpx;
        right: 5rpx;
        height: 60rpx;
        line-height: 60rpx;
        border-radius: 35rpx;
        padding: 0 25rpx;
        font-size: 28rpx;
        position: absolute;
        background: #ffe600;
      }
    }
    .qr-code {
      line-height: 70rpx;
      padding-left: 20rpx;
      .icon-weibiaoti--17 {
        font-size: 50rpx;
        color: #000;
      }
    }
  }
  .search-layout-input {
    padding: 20rpx;
    .search-box {
      border: 2rpx solid #ffe600;
      border-radius: 40rpx;
      padding: 10rpx 20rpx;
      .search-input-box {
        display: flex;
        align-items: center;
        height: 70rpx;
        .icon-weibiaoti--10 {
          font-size: 40rpx;
        }
        .search-input {
          height: 100%;
          line-height: 70rpx;
          padding-left: 10rpx;
          box-sizing: border-box;
          color: #000;
          border-radius: 40rpx;
          background: #fff;
          font-size: 30rpx;
          font-weight: 300;
          //   placeholder样式修改
          .placeholder-style {
            color: #000;
          }
        }
      }
      .search-icon {
        margin-top: 20rpx;
        display: flex;
        justify-content: space-between;
        align-items: center;
        height: 60rpx;
        line-height: 60rpx;
        margin-bottom: 10rpx;
        .ai-text {
          background: #f7f7f7;
          margin-top: 5rpx;
          height: 50rpx;
          line-height: 50rpx;
          padding: 0 20rpx;
          border-radius: 10rpx;
          display: flex;
          align-items: center;
          color: #333;
          font-weight: 400;
          .icon-text {
            margin-left: 6rpx;
            font-size: 26rpx;
          }
        }
        .right-content {
          display: flex;
          align-items: center;
          .icon-weibiaoti--44 {
            font-size: 40rpx;
            margin-right: 20rpx;
            font-weight: 500;
          }
          .search-btn {
            border-radius: 35rpx;
            padding: 0 25rpx;
            font-size: 28rpx;
            background: #ffe600;
          }
        }
      }
    }
  }
}
</style>
